<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ include file="/commons/taglibs.jsp" %>
<%@ include file="/commons/script.jsp" %>
<script type="text/javascript" src='${r"${ctx}"}/assets/js/pinyin_dict_notone.js'></script>
<script type="text/javascript" src='${r"${ctx}"}/assets/js/pinyinUtil.js'></script>
<body>
<script>
jQuery(function($) {
	formvalidation("#addForm")
	$("#saveBtn").click(function(){
		$("#addForm").submit();
	})	
	<#if table.containsDateTimeField>
	addDateTimePicker(".datetime")
	</#if>
	<#if table.containsTimeField>
	addTimePicker(".time")
	</#if>
	<#if table.containsDateField>
	addDatePicker(".date")	
	</#if>
	
})
</script>
<fmt:message key="label.pleaseInput" var="pleaseInput"></fmt:message>
<#list table.editColumnList as column>
<#if !column.baseField>
<fmt:message key="${ClassName }.${column.javaField }.title" var="${column.javaField }Title"/>
</#if>
</#list>
<custom:message/>
	<form:form action='${r"${ctx}"}/${table.tableJavaName}/popup/save' id="addForm" name="addForm" modelAttribute="${table.tableJavaName }" method="post">
		<form:hidden path="id"/>
		<#list table.editColumnList as column>
		<#if !column.baseField>
		<div class="form-group">
			<label class="control-label col-md-2 col-xs-12 col-sm-2"> <#if !column.nullable><span class="required">*</span></#if>
			${"$"}{${column.javaField}Title}
			</label>
			<div class="col-md-4 col-xs-12 col-sm-4">
			
				<#if column.fk>
				<form:select path="${column.referenceColumn.columnNameJavaField}.${column.referenceColumn.referenceColumnJavaField}" cssClass="form-control" ${column.jsValidation }>
					<form:option value=""><fmt:message key="selection.label.pleaseselectone"></fmt:message></form:option>
					<form:options items='${ "${" +column.javaField+"List}"}' itemLabel="${column.referenceColumn.referencedDisplayName}" itemValue="id"/>
				</form:select>
				<label class="error help-block"><form:errors path="${column.referenceColumn.columnNameJavaField}.${column.referenceColumn.referenceColumnJavaField}" /></label>
				<#elseif column.sqlDateField>
				<div class="input-group date" data-date-format="dd/mm/yyyy">
					<form:input path="${column.javaField}" cssClass="form-control" readonly="true"/> 
					<span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
					<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
				</div>
				<label class="error help-block"><form:errors path="${column.javaField}" /></label>
				<#elseif column.timeField>
				<div class="input-group date time" data-date-format="hh:ii">
					<form:input path="${column.javaField}" cssClass="form-control" readonly="true"/> 
					<span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
					<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
				</div>
				<label class="error help-block"><form:errors path="${column.javaField}" /></label>
				<#elseif column.timestampField>
				<div class="input-group date datetime" data-date-format="dd/mm/yyyy hh:ii">
					<form:input path="${column.javaField}" cssClass="form-control" readonly="true"/> 
					<span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
					<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
				</div>
				<label class="error help-block"><form:errors path="${column.javaField}" /></label>
				<#elseif column.bitField>
				<form:checkbox path="${column.javaField}"/>
				<#elseif column.textareaField>
				<form:textarea path="${column.javaField}" cssClass="form-control" rows="3" ${column.jsValidation }/>
				<#elseif column.dataDictField>
				<form:select path="${column.javaField}" cssClass="form-control" ${column.jsValidation }>
					<form:option value=""><fmt:message key="selection.label.pleaseselectone"></fmt:message></form:option>
					<form:options items='${"${" + column.javaField + "Map}"}'/>
				</form:select>
				<label class="error help-block"><form:errors path="${column.javaField}" /></label>
				<#else>
				<form:input path="${column.javaField}" cssClass="form-control"  placeHolder='${r"${pleaseInput}"} ${"$"}{${column.javaField}Title}'  />
				<label class="error help-block"><form:errors path="${column.javaField}" /></label>
				</#if>
			</div>
		</div>
		</#if>
		
		</#list>
		
		<div class="form-group">	
				<div class="col-md-12 col-xs-12 col-sm-12">
					<a id="saveBtn" class="btn btn-primary"><fmt:message key="navigation.button.save"></fmt:message> </a>
					<a id="cancelBtn" class="btn btn-danger"  onclick="top.Dialog.close()"><fmt:message key="navigation.button.cancel"/></a>
					
				</div>
		</div>
		<div id="afterupdate"></div>
	</form:form>
</body>
